package com.comac.tasks.manager.app.config;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Configuration;

/**
 * @Description
 * @Author lihao
 * @Date 2022/1/14 15:30
 */
@Configuration
@EnableConfigurationProperties({TaskFeignProperties.class})
@EnableFeignClients(basePackages = "com.comac.tasks.manager.app.feign")
public class TaskFeignAutoConfiguration implements RequestInterceptor {

    @Autowired
    private TaskFeignProperties taskFeignProperties;

    @Override
    public void apply(RequestTemplate requestTemplate) {
        //设置访问信息
        requestTemplate.header("app-code", taskFeignProperties.getAppCode());
        requestTemplate.header("app-access-key", taskFeignProperties.getAppAccessKey());
    }
}
